package com.wc.AlgoOJ_train.train1.c7.A705;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/11 10:15
 * @description 一只小蜜蜂...
 * http://43.138.190.70:8888/p/A705
 */
public class Main {
    static FastReader sc = new FastReader();

    public static void main(String[] args) {
        long[][] dp = new long[31][2];
        dp[1][0] = 1;
        dp[1][1] = 1;
        for (int i = 2; i <= 30; i++) {
            dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
            dp[i][1] = dp[i][0] + dp[i - 1][1];

        }
        int n = sc.nextInt();
        while (n-- > 0) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            // 把a移动到1的位置
            // 把b也移动1的位置
            System.out.println(dp[(b - a) / 2 + 1][(b - a) & 1]);
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
}
